'use strcit'
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

//各种自定义存储的状态值
const state = {
  // userInfo: {'e_id': 'GL0001', 'e_level': 1},
  // isLogin: true,
  userInfo: {},
  isLogin: false,
  imgSrc: '',
  printStat: true
}
const actions = {
  modifyLoginState (context, obj) {
    context.commit('setLevel', obj)
  },
  userExitState (context, value) {
    context.commit('setUserExitState', value)
  },
  modifyImgSrc (context, v) {
    context.commit('setImgSrc', v)
  }
}
//各种自定义操作方法
const mutations = {
  setLevel (state, obj) {
    state.isLogin = true
    state.userInfo = obj
  },
  setUserExitState (state, v) {
    state.isLogin = v
    state.userInfo = {}
  },
  setImgSrc (state, v) {
    state.imgSrc = v
    state.printStat = !state.printStat
  }
}
const getters = {
  modifyIsLogin: state => {
    console.log(state.isLogin)
    return state.isLogin
  }
}

export default new Vuex.Store({
  state,
  actions,
  mutations,
  getters
})
